package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.QqChannel;
import com.ruoyi.system.service.IQqChannelService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * QQ和渠道关联，记录每个qq在哪个渠道的哪个游戏上的等级 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-06-01
 */
@Controller
@RequestMapping("/system/qqChannel")
public class QqChannelController extends BaseController
{
    private String prefix = "system/qqChannel";
	
	@Autowired
	private IQqChannelService qqChannelService;
	
	@RequiresPermissions("system:qqChannel:view")
	@GetMapping()
	public String qqChannel()
	{
	    return prefix + "/qqChannel";
	}
	
	/**
	 * 查询QQ和渠道关联，记录每个qq在哪个渠道的哪个游戏上的等级列表
	 */
	@RequiresPermissions("system:qqChannel:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(QqChannel qqChannel)
	{
		startPage();
        List<QqChannel> list = qqChannelService.selectQqChannelList(qqChannel);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出QQ和渠道关联，记录每个qq在哪个渠道的哪个游戏上的等级列表
	 */
	@RequiresPermissions("system:qqChannel:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QqChannel qqChannel)
    {
    	List<QqChannel> list = qqChannelService.selectQqChannelList(qqChannel);
        ExcelUtil<QqChannel> util = new ExcelUtil<QqChannel>(QqChannel.class);
        return util.exportExcel(list, "qqChannel");
    }
	
	/**
	 * 新增QQ和渠道关联，记录每个qq在哪个渠道的哪个游戏上的等级
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存QQ和渠道关联，记录每个qq在哪个渠道的哪个游戏上的等级
	 */
	@RequiresPermissions("system:qqChannel:add")
	@Log(title = "QQ和渠道关联，记录每个qq在哪个渠道的哪个游戏上的等级", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(QqChannel qqChannel)
	{		
		return toAjax(qqChannelService.insertQqChannel(qqChannel));
	}

	/**
	 * 修改QQ和渠道关联，记录每个qq在哪个渠道的哪个游戏上的等级
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		QqChannel qqChannel = qqChannelService.selectQqChannelById(id);
		mmap.put("qqChannel", qqChannel);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存QQ和渠道关联，记录每个qq在哪个渠道的哪个游戏上的等级
	 */
	@RequiresPermissions("system:qqChannel:edit")
	@Log(title = "QQ和渠道关联，记录每个qq在哪个渠道的哪个游戏上的等级", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(QqChannel qqChannel)
	{		
		return toAjax(qqChannelService.updateQqChannel(qqChannel));
	}
	
	/**
	 * 删除QQ和渠道关联，记录每个qq在哪个渠道的哪个游戏上的等级
	 */
	@RequiresPermissions("system:qqChannel:remove")
	@Log(title = "QQ和渠道关联，记录每个qq在哪个渠道的哪个游戏上的等级", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(qqChannelService.deleteQqChannelByIds(ids));
	}
	
}
